package com.cmb.lk50.pojo;

import org.bson.BsonReader;
import org.bson.BsonWriter;
import org.bson.codecs.Codec;
import org.bson.codecs.DecoderContext;
import org.bson.codecs.EncoderContext;
import org.springframework.stereotype.Component;

/**
 * Author       : 蒋俊钊 80256973
 * Date         : 2020/8/25
 * Copyright    (C) ChinaMerchantsBank
 */
@Component
public class CustomCode implements Codec<CustomBody> {
    @Override
    public CustomBody decode(BsonReader reader, DecoderContext decoderContext) {
        return null;
    }

    @Override
    public void encode(BsonWriter writer, CustomBody value, EncoderContext encoderContext) {
        writer.writeStartDocument();
        writer.writeString("testField", value.name);
        writer.writeEndDocument();
    }

    @Override
    public Class<CustomBody> getEncoderClass() {
        return CustomBody.class;
    }
}
